$(function(){
    toastr.options = {
        "newestOnTop": false,
        "timeOut": 1500,
        "extendedTimeOut": 0,
        "escapeHtml": true,
        "positionClass": "toast-bottom-center"
    };

    var getParams = getArgs();
    window.currentMainHotel = getParams.no;
    if (window.currentMainHotel === undefined || window.currentMainHotel === '') {
        toastr.error(lang('toastr.grogshop'));
        return;
    }
    toggleLoading(true);
    ajaxRequest('/Home/Hotel/publicLink', {
        'id': window.currentMainHotel
    }, 'post', function (data) {
        toggleLoading(false);
        var hotelInfo = data.data;
        $(document).attr('title', hotelInfo.name);
        $('#doc-header .navbar-title').html(hotelInfo.name);
        $('#hotel-main-cover .inner-item').attr('data-original', hotelInfo.imageUrl).lazyload();
        if (hotelInfo.hotels.length === 0) {
        	$('#sub-hotel-empty').removeClass('hidden');
        	return;
        }
        var subHotelHTML = '';
        var templateSubHotelHTML = $($('#templateSubHotel').clone().html());
        $.each(hotelInfo.hotels, function (key, subHotelInfo) {
            templateSubHotelHTML.find('.picture-title-title').html(subHotelInfo.name === '' ? lang('noName') : subHotelInfo.name);
            templateSubHotelHTML.find('.picture-title-picture').attr('data-original', subHotelInfo.imageUrl);
            templateSubHotelHTML.attr('href', '/Home/BookPage/index?hotel='+subHotelInfo.id);
            subHotelHTML += templateSubHotelHTML.prop('outerHTML');
        });
        $('#sub-hotel-container').html(subHotelHTML);
        $('#sub-hotel-container .picture-title-picture').lazyload();
    }, function (error) {
        toggleLoading(false);
        toastr.error(typeof error.responseJSON === 'undefined' ? lang('tip.system') : error.responseJSON.info);
    });
	$('#sub-hotel-container').html();
});